Skip to content

Conversation

@phofl
Copy link
Member

@phofl phofl commented Jan 4, 2021

Minor regex improvements.
Is a fixture the right thing to do here?

@phofl phofl added Clean IO CSV read_csv, to_csv labels Jan 4, 2021
decimal = re.escape(self.decimal)
if self.thousands is None:
regex = fr"^\-?[0-9]*({decimal}[0-9]*)?([0-9](E|e)\-?[0-9]*)?$"
regex = fr"^[\-|\+]?[0-9]*({decimal}[0-9]*)?([0-9]?(E|e)\-?[0-9]+)?$"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the | necessary inside []?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, thanks.

("1_,", 1.0),
("1_234,56", 1234.56),
("1_234,56e0", 1234.56),
# negative cases; must not parse as float
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add something in the docstring about this, i.e. how to interpret the tuple

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done

@jreback jreback added this to the 1.3 milestone Jan 4, 2021
@jreback jreback merged commit 1f22da1 into pandas-dev:master Jan 4, 2021
@jreback
Copy link
Contributor

jreback commented Jan 4, 2021

very nice @phofl

@phofl phofl deleted the 38926 branch January 4, 2021 23:23
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Clean IO CSV read_csv, to_csv

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLN: Unify number recognition tests in read_csv for all parsers

3 participants